@@ -18,6 +18,7 @@ module Agents |
||
18 | 18 |
if agent = current_user.agents.find_by(id: params[:agent_id]) |
19 | 19 |
# POST /agents/:id/dry_run |
20 | 20 |
if attrs.present? |
21 |
+ attrs.merge!(memory: agent.memory) |
|
21 | 22 |
type = agent.type |
22 | 23 |
agent = Agent.build_for_type(type, current_user, attrs) |
23 | 24 |
end |
@@ -100,5 +100,22 @@ describe Agents::DryRunsController do |
||
100 | 100 |
results = assigns(:results) |
101 | 101 |
expect(results[:log]).to match(/^\[\d\d:\d\d:\d\d\] INFO -- : Fetching #{Regexp.quote(url_from_event)}$/) |
102 | 102 |
end |
103 |
+ |
|
104 |
+ it "uses the memory of an existing Agent" do |
|
105 |
+ valid_params = { |
|
106 |
+ :name => "somename", |
|
107 |
+ :options => { |
|
108 |
+ :code => "Agent.check = function() { this.createEvent({ 'message': this.memory('fu') }); };", |
|
109 |
+ } |
|
110 |
+ } |
|
111 |
+ agent = Agents::JavaScriptAgent.new(valid_params) |
|
112 |
+ agent.memory = {fu: "bar"} |
|
113 |
+ agent.user = users(:bob) |
|
114 |
+ agent.save! |
|
115 |
+ post :create, agent_id: agent, agent: valid_params |
|
116 |
+ results = assigns(:results) |
|
117 |
+ expect(results[:events][0]).to eql({"message" => "bar"}) |
|
118 |
+ end |
|
119 |
+ |
|
103 | 120 |
end |
104 | 121 |
end |